#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

if [ ! -f "${PWD}/config/configuration.yaml" ]; then
  mkdir -p "${PWD}/config"
  hass --config "${PWD}/config" --script ensure_config
  echo "Creating default configuration."
  echo "
default_config:

logger:
  default: info
  logs:
    homeassistant.components.vacuum: debug
    custom_components.deebot: debug
    deebot_client: debug

# If you need to debug uncomment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
debugpy:
#   wait: true
" >> "${PWD}/config/configuration.yaml"
fi

# Set the python path to include our custom_components directory
export PYTHONPATH="${PYTHONPATH}:${PWD}/custom_components"

# Start Home Assistant
hass --config "${PWD}/config" --debug